package servlet.Person;

import service.person.PersonService;
import service.person.PersonServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class oneBM extends HttpServlet {
    private static final long serialVersionUID = 1L;
    PersonService personService = new PersonServiceImpl();

    public oneBM() {
        super();
        // TODO Auto-generated constructor stub
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        String name = request.getParameter("name");
        String sex = request.getParameter("sex");
        System.out.print(request.getParameter("age"));
        int age = Integer.parseInt(request.getParameter("age"));
        String phone = request.getParameter("phone");
        String idcard = request.getParameter("idcard");
        int i = personService.onePerson(name, sex, age, phone, idcard);
        if (i > 0) {

            response.sendRedirect(request.getContextPath() + "/end.jsp?msg=1");
        } else {
            response.sendRedirect(request.getContextPath() + "/end.jsp?msg=0");
        }
    }
}